/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerDoctorLogin {
     /**
     * variables and views declarations
     */
    
    Views.DoctorLogin docLogin;
    ActionListener actionListener;
    Model.MainModel model;
    
    /**
     *  Default Constructor to instantiate views
     */
    
public ControllerDoctorLogin( ){
        docLogin = new Views.DoctorLogin();
        docLogin.setVisible(true);
        model=new Model.MainModel();
}
     
    
/**
 * Method to add actionListener to clicked buttons
 */
     public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==docLogin.getDLoginBtn()){
                      if((docLogin.getDUsername().getText().equals("visitor"))&&(docLogin.getDPassword().getText().equals("visitor"))){
                        ControllerDoctorHomepage docHomepage= new ControllerDoctorHomepage();  
                        docHomepage.control();
                        docLogin.setVisible(false);
                        }
                      else{
                        model.showDoctor(docLogin);
                      }
                  }
                                    
              }
              
        };                
        docLogin.getDLoginBtn().addActionListener(actionListener);
    }  
    
}
